package day_2022_4_to_7.day48;

/**
 * @author haomin
 * @date 2022/05/23 21:57
 **/
import java.util.Scanner;

public class Day25_2_NumToString {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while(input.hasNext()){
            String a=input.next();
            int num;
            do{
                num=0;
                for(int i=0;i<a.length();i++){
                    num+=a.charAt(i)-48;
                }
                a=num+"";
            }while(num>=10);
            System.out.println(num);
        }
        input.close();
    }
}